
    /* 查看订单详细 */
    function catorder(name) {
        layer.open({
            type: 2,
            title: '<h4>查看订单详细</h4>',
            shadeClose: true,
            shade: 0.8,
            area: ['850px', '90%'],
            content:name //iframe的url
        });
    }

    /* 编辑订单 */
    function editquanxian(name) {
        $.get(name,function(msg){
            // console.log(msg);
            if(msg.status == 1){
                location.href=msg.url;
            }else{
                layer.msg(msg.msg, {icon: msg.icon});
            }
        });
    }
    /* 删除订单 */
    function del(name){
        layer.confirm('您确实删除订单？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post(name,function(data){
                // console.log(data);

                if(data.status==2){
                    var ico=2;
                }else if(data.status==1){
                    var ico=1;
                }else if(data.status==0){
                    var ico=2;
                }else{
                    var ico=4;
                }
                layer.msg(data.msg, {
                    icon: ico,
                    time:2000,
                },function(){
                    history.go(0);
                });

            });

        });
    }

    /* 查看某订单日志 */
    function catlog(name) {
        layer.open({
            type: 2,
            title: '日志查看',
            shadeClose: true,
            shade: 0.8,
            area: ['70%', '90%'],
            content:name //iframe的url
        });
    }

    /* 分配订单 */
    function fenpei(name) {
        $.post(name,function(data){
            if(data.status == 0 || data.code == 0){
                layer.msg(data.msg, {
                    icon: data.icon,
                    time:2000,
                },function(){
                    history.go(0);
                });
            }else{
                layer.open({
                    type: 2,
                    title: '订单分配',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['70%', '90%'],
                    content:name //iframe的url
                });
            }
        });
    }

    /*微信推送*/
    function pushweixin(name) {
        $.get(name,function(data){
            if( data.status == 0 || data.code == 0 ){
                layer.msg(data.msg, {
                    icon: data.icon,
                    time:2000,
                },function(){
                    history.go(0);
                });
            }else{
                layer.open({
                    type: 2,
                    title: '微信推送',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['35%', '50%'],
                    content:name //iframe的url
                });
            }
        });
    }

    /*短信发送*/
    function sendmessage(name) {
        $.get(name,function(data){
            // console.log(data);
            if( data.status == 0 || data.code == 0 ){
                layer.msg(data.msg, {
                    icon: data.icon,
                    time:2000,
                },function(){
                    history.go(0);
                });
            }else{
                // console.log(data);
                layer.open({
                    type: 2,
                    title: '短信发送',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['40%', '70%'],
                    content:name //iframe的url
                });
            }
        });
    }

    // function selectziduan(name) {
    //     $.get(name,function(data){
    //         // console.log(data);
    //         if( data.status == 0 || data.code == 0 ){
    //             layer.msg(data.msg, {
    //                 icon: data.icon,
    //                 time:2000,
    //             },function(){
    //                 history.go(0);
    //             });
    //         }else{
    //             // console.log(data);
    //             layer.open({
    //                 type: 2,
    //                 title: false,
    //                 area: ['1000px', '560px'],
    //                 shadeClose: true, //点击遮罩关闭
    //                 content: name
    //             });
    //         }
    //     });
    // }



    $(function(){
        var city = $('#city');
        var area = $('#area');
        var yiyuan = $('#yiyuan');
        city.change(function(){
            area.empty();
            $("<option value=''>"+'请选择区域'+"</optinon>").appendTo(area);
            yiyuan.empty();
            $("<option value=''>"+'请选择医院'+"</optinon>").appendTo(yiyuan);
            $.post("/admin/yewu/getArea", {city:$(this).val()},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"'>"+n.name+"</optinon>").appendTo(area);
                    });
                }
            });
        });
        area.change(function(){
            yiyuan.empty();
            $("<option value=''>"+'请选择医院'+"</optinon>").appendTo(yiyuan);
            $.post("/admin/yewu/getyiyuan", {area:$(this).val()},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"'>"+n.name+"</optinon>").appendTo(yiyuan);
                    });
                }
            });
        });

        var hsmd = $('#hsmd');
        var hszy = $('#hszy');
        hsmd.change(function(){
            hszy.empty();
            $("<option value=''>"+'请选择专员'+"</optinon>").appendTo(hszy);
            $.post("/admin/yewu/gethszy", {hsmd:$(this).val()},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"'>"+n.username+"</optinon>").appendTo(hszy);
                    });
                }
            });
        });

        $('#fkbm').change(function () {
            $('#fkry').empty();
            $("<option value=''>"+'请选择反馈人员'+"</optinon>").appendTo($('#fkry'));
            $.post("/admin/yewu/getUser", {bumen:$(this).val()},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"'>"+n.username+"</optinon>").appendTo($('#fkry'));
                    });
                }
            });
        });
        $('#qd_depar').change(function () {
            $('#jdry').empty();
            $("<option value=''>"+'请选择建单人员'+"</optinon>").appendTo($('#jdry'));
            $.post("/admin/yewu/getUser", {bumen:$(this).val()},function(data){
                if(data.code!=0){
                    $.each(eval(data),function(i,n){
                        $("<option value='"+n.id+"'>"+n.username+"</optinon>").appendTo($('#jdry'));
                    });
                }
            });
        });

    });


    $(function () {
        $('.color1').addClass('lable label-default');//未跟进
        $('.color2').addClass('lable label-warning');//拍摄取消
        $('.color3').addClass('lable label-default');//无效客资
        $('.color4').addClass('lable label-primary');//待跟进
        $('.color5').addClass('lable label-success');//预约成功
        $('.color6').addClass('lable label-danger');//拍摄成功
        $('.color7').addClass('lable label-info');//意向客资
        $('.color9').addClass('lable label-warning');//预约未到
    });
    //导出Excel使用
    $("#button").click(function(){
        $("form").attr("action", "/admin/excel/exceldc");
        $('form').submit();
        setTimeout($("form").attr("action", "/admin/yewu/olist")
            , 5000);
        return false;
    });




